package com.yxw.live_vod_boot.controller;

import com.yxw.live_vod_boot.dto.OnDemandCommentDTO;
import com.yxw.live_vod_boot.dto.OnDemandReplyCommentDTO;
import com.yxw.live_vod_facade.dto.PageOnDemandCommentDTO;
import com.yxw.live_vod_boot.dto.TopOnDemandCommentDto;
import com.yxw.live_vod_boot.service.OnDemandCommentService;
import com.yxw.live_vod_facade.vo.OnDemandCommentVO;
import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.common.helper.ResultHelper;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 点播评论管理
 * @author liuxin
 * @date 2023.11.15
 */
@RestController
@Api(value = "点播评论管理", tags = "点播评论管理")
@Slf4j
@RequestMapping("/api/onDemand/comment")
public class OnDemandCommentController {

    @Autowired
    private OnDemandCommentService onDemandCommentService;

    @ApiOperation(value = "新增点播评论")
    @PostMapping(value = "/addComment")
    public BaseResult addComment(@RequestBody @Validated OnDemandCommentDTO dto) {
        OnDemandCommentVO vo=onDemandCommentService.addComment(dto);
        return BaseResult.doSuccess(vo,"评论成功");
    }

    @ApiOperation(value = "新增点播回复")
    @PostMapping(value = "/addReplyComment")
    public BaseResult addReplyComment(@RequestBody @Validated OnDemandReplyCommentDTO dto) {
        OnDemandCommentVO vo= onDemandCommentService.addReplyComment(dto);
        return BaseResult.doSuccess(vo,"回复成功");
    }

    @ApiOperation(value = "查询与我相关的直播评论或者回复")
    @PostMapping(value = "/pageRelatedComments")
    public BaseResult<PageVO<OnDemandCommentVO>>  pageRelatedComments(@RequestBody PageOnDemandCommentDTO dto) {
        PageVO<OnDemandCommentVO> voList= onDemandCommentService.pageRelatedComments(dto);
        return ResultHelper.fillWithSuccess(voList);
    }

    @ApiOperation(value = "查询视频下面的评论和回复")
    @PostMapping(value = "/pageVideoComments")
    public BaseResult<PageVO<OnDemandCommentVO>>  pageVideoComments(@RequestBody PageOnDemandCommentDTO dto) {
        PageVO<OnDemandCommentVO> voList= onDemandCommentService.pageVideoComments(dto);
        return ResultHelper.fillWithSuccess(voList);
    }

    @ApiOperation(value = "评论/取消置顶")
    @PostMapping(value = "/topComments")
    public BaseResult  topComments(@Validated @RequestBody TopOnDemandCommentDto dto) {
        onDemandCommentService.topComments(dto);
        return BaseResult.doSuccess(null,"置顶成功");
    }
    @ApiOperation(value = "删除评论")
    @PostMapping(value = "/deleteCommentById")
    public BaseResult  deleteCommentById(@RequestBody Long commentId) {
        onDemandCommentService.deleteCommentById(commentId);
        return BaseResult.doSuccess(null,"删除成功");
    }
}
